<template>
  <div class="info_config_page">
    <div class="common_form_search">
      <el-form ref="searchForm" :inline="true" :model="searchForm" class="form-inline">
        <el-form-item label="订单号">
          <el-input v-model="searchForm.orderNo" placeholder="请输入订单号" />
        </el-form-item>
        <!-- <el-form-item label="供应商ID">
          <el-input
            v-model="searchForm.trade_id"
            placeholder="请输入供应商ID"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="商品名称">
          <el-input v-model="searchForm.name" placeholder="请输入商品名称" />
        </el-form-item>
        <!-- <el-form-item label="供应商">
          <el-input
            v-model="searchForm.cert_name"
            placeholder="请输入供应商"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="上链状态">
          <el-select v-model="searchForm.status" clearable placeholder="请选择">
            <el-option :value="0" label="未上链" />
            <el-option :value="1" label="已上链" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button size="small" @click="search()" type="primary">查询</el-button>
          <el-button size="small" @click="reset()">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-divider></el-divider>

    <div class="flex align-center table-top-btns">
      <h5 class="flex align-center">
        <svg-icon style="margin-right: 15px" icon-class="list" :size="15" />数据列表
      </h5>
    </div>
    <el-table :data="tableData" border>
      <el-table-column align="center" header-align="center" fixed prop="id" label="ID" width="60" />
      <el-table-column align="center" header-align="center" fixed prop="order_no" label="订单ID" width="200" />
      <el-table-column align="left" header-align="center" label="产品信息">
        <!-- width="320" -->
        <template slot-scope="scope">
          <div>
            <span class="span-info">产品名称：</span>{{ scope.row.goods_title }}
          </div>
          <div>
            <span class="span-info">产品数量：</span>{{ scope.row.amount }}
          </div>
          <div>
            <span class="span-info">商品编码：</span>{{ scope.row.goods_id }}
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column
        align="center"
        header-align="center"
        prop="cidddddd"
        label="唯⼀标识码"
      /> -->
      <el-table-column align="center" header-align="center" prop="goods_version_id" label="商品版本" />
      <!-- <el-table-column
        align="center"
        header-align="center"
        prop="login_timeff"
        label="供应商ID"
      />
      <el-table-column align="center" header-align="center" label="供应商">
        <template slot-scope="scope">
          <span>{{ scope.row.zlf_info.name }}</span>
        </template>
      </el-table-column> -->
      <el-table-column align="center" header-align="center" prop="chain_time" label="上链时间" width="100" />
      <el-table-column align="center" header-align="center" prop="chain_status" label="上链状态" width="100">
        <template slot-scope="scope">
          <el-tag class="pointer" :type="scope.row.chain_status === 0 ? 'primary' : 'success'" @click="getParams(scope.row.chain_params)" disable-transitions>
            {{ scope.row.chain_status == 0 ? "未上链" : "已上链" }}
          </el-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column
        fixed="right"
        label="操作"
        width="100"
      >
        <template slot-scope="scope">
          <div class="operate_col">
            <el-button
              v-if="scope.row.chain_status === 0 && scope.row.trade_no != ''? true : false"
              @click="onChain(scope.row)"
              type="primary"
              size="small"
            >
              上链
            </el-button>
          </div>
        </template>
      </el-table-column> -->
    </el-table>
    <custom-page ref="customPage" :total="total" @getList="getList" />
    <param-dialog :dialogVisible="dialogVisible" :dialogType="dialogType" :requestInfo="requestInfo" :responseInfo="responseInfo" @close="closeDialog" />
  </div>
</template>

<script>
import { getGoodsList } from '@/api/lease'
import customPage from '@/components/customPage'
import paramDialog from './child/paramDialog.vue'
export default {
  components: { customPage, paramDialog },
  data() {
    return {
      tableData: [],
      total: 0,
      searchForm: {
        orderNo: '',
        name: '',
        status: ''
      },
      dialogVisible: false,
      dialogType: 1,
      requestInfo: {},
      responseInfo: {}
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    search() {
      this.$refs.customPage.page = 1
      this.getList()
    },
    // 重置
    reset() {
      this.searchForm = Object.assign({})
      this.getList()
    },
    getParams(row) {
      this.dialogType = 2
      this.dialogVisible = true
      let info = JSON.parse(row)
      this.requestInfo = info.request ? JSON.parse(info.request.biz_content) : {}
      this.responseInfo = info.response ? info.response : {}
    },
    closeDialog() {
      this.dialogVisible = false
    },
    onChain(row) {
      this.dialogType = 1
      this.dialogVisible = true
    },
    // 获取列表
    getList() {
      const { page, pageSize } = this.$refs.customPage
      getGoodsList({
        page,
        pageSize,
        ...this.searchForm
      }).then((res) => {
        this.tableData = res.data
        this.total = res.total
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
